package com.itcast.config;

import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TtlConfig {
    @Bean
    public Queue simpleQueue() {
        return QueueBuilder.nonDurable("simpleQueue").deadLetterRoutingKey("dead")
                .deadLetterExchange("deadExchange").ttl(1000).build();
    }
    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("directExchange",false,false);
    }
    @Bean
    public Binding bindingQueue() {
        return BindingBuilder.bind(simpleQueue()).to(directExchange()).with("direct");
    }
    @Bean
    public Queue deadQueue() {
        return QueueBuilder.nonDurable("deadQueue").ttl(1000).deadLetterRoutingKey("dead2")
                .deadLetterExchange("deadExchange2").build();
    }
    @Bean
    public DirectExchange deadExchange() {
        return new DirectExchange("deadExchange",false,false);
    }
    @Bean
    public Binding bindingDeadQueue() {
        return BindingBuilder.bind(deadQueue()).to(deadExchange()).with("dead");
    }
    @Bean
    public Queue deadQueue2() {
        return QueueBuilder.nonDurable("deadQueue2").ttl(1000).deadLetterRoutingKey("dead2")
                .deadLetterExchange("deadExchange2").build();
    }
    @Bean
    public DirectExchange deadExchange2() {
        return new DirectExchange("deadExchange2",false,false);
    }
    @Bean
    public Binding bindingDeadQueue2() {
        return BindingBuilder.bind(deadQueue2()).to(deadExchange2()).with("dead2");
    }

}

